﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Composite.Data;

public partial class Admin_LCAFlow_Controls_FlowRow : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void RefreshComponents()
    {
        using (DataConnection conn = new DataConnection())
        {
            var units = from u in conn.Get<LCA.Data.Unit>()
                        join uc in conn.Get<LCA.Data.UnitGroup>() on u.UnitGroup equals uc.Id
                        select new
                        {
                            Id = u.Id,
                            Name = uc.Name + " - " + u.Name
                        };
            units = units.OrderBy(x => x.Name);

            ddlUnit.DataSource = units;
            ddlUnit.DataBind();
            ddlUnit.SelectedValue = "d3aa52a4-84a7-46b6-8d65-afd4aed9f7af";
            //ddlUnit.Items.Insert(0, new ListItem("-- Please Select --", "NULL"));

        }
    }
}